package com.ayoka.ui.course.course_estimate;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.ayoka.R;
import com.ayoka.base.BaseActivity;
import com.ayoka.databinding.ActivityCourseEstimateReportBinding;
import com.ayoka.mvp.CourseEstimateMVP;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.CourseEstimateDescriptionBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.CourseEstimateReportBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.ResponseCourseEstimateBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.CourseEstimateRecordBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.CourseEstimateResultBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimateModel.CourseEstimateInformationBean;
import com.ayoka.mvp.CourseEstimateMVP.CourseEstimatePresenter;
import com.ayoka.mvp.CourseEstimateMVP.ICourseEstimateView;
import com.jcp.baselibrary.model.ToolBarOptions;
import com.jcp.baselibrary.utils.StatusBarUtils;
import com.jcp.baselibrary.utils.StringUtil;

/**
 * =========================================================
 * @ProjectName:
 * @ClassName: CourseEstimateReportActivity
 * @Description:
 * @Author: jincp
 * @CreateDate: 2019/3/28 12:53
 * =========================================================
 */
public class CourseEstimateReportActivity extends BaseActivity<ActivityCourseEstimateReportBinding, CourseEstimatePresenter> implements ICourseEstimateView {

    public static void start(Activity activity, long recordId) {
        Intent intent = new Intent(activity, CourseEstimateReportActivity.class);
        intent.putExtra("RecordId", recordId);
        activity.startActivity(intent);
    }

    private long recordId;

    @Override
    protected void configIntentValue() {
        recordId = getIntent().getLongExtra("RecordId", 0);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_course_estimate_report;
    }

    @Override
    protected void initViews() {
        mDataBinding.btnComplete.setOnClickListener(this);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions(R.string.estimate_report);
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        mPresenter.getCourseEstimateReportData(recordId);
    }

    @Override
    protected CourseEstimatePresenter getPresenter() {
        return new CourseEstimatePresenter();
    }


    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view == mDataBinding.btnComplete) {
            onBackPressed();
        }
    }

    @Override
    public void configCourseEstimateDescriptionData(CourseEstimateDescriptionBean courseEstimateDescriptionBean) {

    }

    @Override
    public void configCourseEstimateDetailData(ResponseCourseEstimateBean data) {

    }

    @Override
    public void onSubmitCourseEstimateCallback(boolean isSuccess, int recordId) {

    }

    @Override
    public void configCourseEstimateReportData(CourseEstimateReportBean courseEstimateReportBean) {
        if (courseEstimateReportBean == null) return;
        if (courseEstimateReportBean.testing_record != null) {
            CourseEstimateRecordBean estimateRecordBean = courseEstimateReportBean.testing_record;
            mDataBinding.tvAssessmentTime.setText(StringUtil.formatString(R.string.format_assessment_date, estimateRecordBean.CreateDate));
            if (estimateRecordBean.TestingInfo != null) {
                CourseEstimateInformationBean informationBean = estimateRecordBean.TestingInfo;
                mDataBinding.tvAssessmentTitle.setText(informationBean.Title);
            }
        }
        if (courseEstimateReportBean.testing_result_assessment != null) {
            CourseEstimateResultBean estimateResultBean = courseEstimateReportBean.testing_result_assessment;
            mDataBinding.tvYourAssessmentResult.setText(R.string.your_assessment_result);
            mDataBinding.tvAssessmentContent.setText(estimateResultBean.Assessment);
            mDataBinding.tvConsult.setText(R.string.consult);
        }
    }

}
